深入C++ string.find()函数的用法总结
cout<<"position "<<i<<" : "<<position<<endl;
string s = ”cdeabcigld“;
复制代码 代码如下:
复制代码 代码如下:
2.如果没有查询到,则返回string::npos,这是一个很大的数,其值不需要知道。flag = "c";
else
cout<<"s.find(b,5) is : "<<position<<endl;
cout << "position is : " << position << endl;
string flag;
复制代码 代码如下:
1.如果string sub = ”abc“;}
cout<<"s.rfind (flag) :"<<position<<endl;
s.find_first_of(sub), s.find_first_not_of(sub), s.find_last_of(sub), s.find_last_not_of(sub) 这四个函数,查找s中含有sub中任意字母的索引。
}
s.find(sub) , s.rfind(sub) 这两个函数,如果完全匹配,才返回匹配的索引,即:当s中含有abc三个连续的字母时,才返回当前索引。
position = s.find("jk");
using namespace std;
////find函数返回类型 size_type
flag="acb12389efgxyz789";
while((position=s.find_first_of(flag,position))!=string::npos)
position=s.rfind (flag);
i++;
{
复制代码 代码如下:
position=s.find("b",5);cout << "s.find_first_of(flag) is : " << position << endl;
void main()
{
string s("1a2b3c4d5e6f7g8h9i1a2b3c4d5e6f7g8ha9i");
position++;
#include <iostream>
}
}
复制代码 代码如下:
//find 函数 返回jk 在s 中的下标位置
#include <string>
flag="3";
position=flag.find_first_not_of (s);
flag="a";
{
复制代码 代码如下:
int i=1;//position=s.find_first_of(flag,position);
//从字符串s 下标5开始,查找字符串b ,返回b 在s 中的下标
//查找s 中flag 出现的所有位置。
//反向查找,flag 在s 中最后出现的位置
string::size_type position;
cout << "Not found the flag" + flag;
说明:
if (position != s.npos) //如果没找到,返回一个特别的标志c++中用npos表示,我这里npos取值是4294967295,
cout<<"flag.find_first_not_of (s) :"<<position<<endl;
position=0;
//查找flag 中与s 第一个不匹配的位置
{
//find 函数 返回flag 中任意字符 在s 中第一次出现的下标位置
相关热词: C++
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/sql/mssql/3237.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
SQL基本教程之行转列Pivo
时间:2021-01-20
-
region from hr.Employees union
时间:2021-01-20
-
有时候需要调整用户权限
时间:2021-01-19
-
(但使用 ORDER BY 子句并不
时间:2021-01-19
-
RAND()*10000)insert into Detail
时间:2021-01-19
-
OR 运算符:在两侧的查询
时间:2021-01-19
-
放假之前老大跟我提起了
时间:2021-01-19
-
数据库的运维计策剧本篇
时间:2021-01-19
热门文章
-
4.与聚合函数和 GROUP BY 子句有关的常见错
时间:2021-01-19
-
SQL Server安全(11/11):审核(Auditing)
时间:2021-01-09
-
sqlserver中查询横表变竖表的sql语句简析
时间:2020-12-08
-
SQL Server简单模式下误删除堆表记录恢复方
时间:2020-12-12
-
关于SQL Server查询语句的使用
时间:2020-12-13
-
MSSQL教程_mssql数据库教程_MSSQL基础教程_第
时间:2020-12-13
-
jdbc连接sql server数据库问题分析
时间:2020-12-10
-
详解SQL游标的用法
时间:2020-12-27
-
sql server 关于设置null的一些建议
时间:2020-12-28
-
mssql关于一个表格结构的另外一种显示(表
时间:2020-12-11
